package com.woniuxy.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.Perm;
import com.woniuxy.entity.PermDto;
import com.woniuxy.service.PermService;
import org.apache.catalina.security.SecurityUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO(用一句话描述这个类的作用)
 * @Author 18452
 * @Date 2021/4/26 18:42
 */

@Controller
@CrossOrigin
@RequestMapping("/perm")
public class PermController {

    @Resource
    private PermService permService;

    @RequestMapping("/select")
    @ResponseBody
    public PageInfo<Perm> select(@RequestBody PermDto permDto){
        System.out.println("-------"+permDto);
        PageInfo<Perm> permPageInfo = permService.select(permDto);
        return permPageInfo;
    }
    @RequestMapping("/selectMenu")
    @ResponseBody
    public List<Perm> selectMenu(){
        List<Perm> permList = permService.selectMenu();
        return permList;
    }
    @RequestMapping("/insert")
    @ResponseBody
    public String insert(@RequestBody Perm perm){
        System.out.println("-------"+perm);
        String result = permService.insert(perm);
        return result;
    }
    @RequestMapping("/update")
    @ResponseBody
    public String update(@RequestBody Perm perm){
        System.out.println("-------"+perm);
        String result = permService.update(perm);
        return result;
    }
    @RequestMapping("/delete")
    @ResponseBody
    public String delete(int id){
        String result = permService.delete(id);
        return result;
    }
}
